package com.microblogforsim.activity;

import androidx.appcompat.app.AppCompatActivity;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpParams;
import com.microblogforsim.R;
import com.microblogforsim.callback.JsonCallback;
import com.microblogforsim.model.LzyResponse;
import com.microblogforsim.model.Topics;
import com.microblogforsim.utils.Urls;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class ChatActivity extends AppCompatActivity implements View.OnClickListener {

    //    返回按钮
    private ImageView btn_back;
    //    标题
    private TextView tv_title;
    //    设置按钮
    private TextView btn_set;
    //    语音按钮
    private ImageView btn_yuyin;
    //    内容编辑框
    private EditText et_content;
    //    表情按钮
    private ImageView btn_biaoqing;
    //    添加按钮
    private ImageView btn_add;
    //    聊天列表
    private ListView lv_chatList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chat);
        init();
    }

    private void init(){
        btn_back = findViewById(R.id.chat_btn_back);
        tv_title = findViewById(R.id.chat_tv_name);
        btn_set = findViewById(R.id.chat_btn_setting);
        btn_yuyin = findViewById(R.id.chat_btn_yuyin);
        et_content = findViewById(R.id.chat_et_content);
        btn_biaoqing = findViewById(R.id.chat_btn_biaoqing);
        btn_add = findViewById(R.id.chat_btn_more);
        lv_chatList = findViewById(R.id.chat_lv_list);
        btn_back.setOnClickListener(this);
        btn_set.setOnClickListener(this);
        btn_yuyin.setOnClickListener(this);
        btn_biaoqing.setOnClickListener(this);
        btn_add.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.chat_btn_back:
                finish();
                break;
            case R.id.chat_btn_setting:
                openSet();
                break;
            case R.id.chat_btn_yuyin:
                yuyin();
                break;
            case R.id.chat_btn_biaoqing:
                biaoqing();
                break;
            case R.id.chat_btn_more:
                add();
                break;
        }
    }

    private void add(){
        Toast.makeText(this, "添加按钮", Toast.LENGTH_SHORT).show();
    }

    private void biaoqing() {
        Toast.makeText(this, "表情按钮", Toast.LENGTH_SHORT).show();
    }

    private void yuyin() {
        Toast.makeText(this, "语音按钮", Toast.LENGTH_SHORT).show();
    }

    private void openSet() {
        Toast.makeText(this, "设置按钮", Toast.LENGTH_SHORT).show();
    }

//    private ImageView ig_yuyin;
//    private ImageView ig_back;
//    String TAG = "tag";
//    String url = "http://shuaishen.top/index.php/admin/Topics/getAll";
//
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_chat);
//        ig_yuyin = (ImageView) findViewById(R.id.chat_btn_yuyin);
//        ig_yuyin.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                okgo();
//            }
//        });
//    }
//
//    private void okgo() {
//        OkGo.<LzyResponse<Topics>>get(Urls.SERVER + "Topics/getAll")//
//                .tag(this)//
//                .headers("header1", "headerValue1")//
//                .params("param1", "paramValue1")//
//                .execute(new JsonCallback<LzyResponse<Topics>>() {
//                    @Override
//                    public void onSuccess(com.lzy.okgo.model.Response<LzyResponse<Topics>> response) {
//                        // handleResponse(response);
//                        Log.d("TAG", "onSuccess: " + response.body().data.getData().size());
//
//                        //                        int i = 0;
////                       while (i<response.body().data.getData().size()){
////                           list.add(response.body().data.getData().get(i));
////                           i++;
////                       }
//
////                        adapter = new TextAdapter(getContext());
////                        adapter.replayAll(list);
////                        lv_list.setAdapter(adapter);
//                    }
//
//                    @Override
//                    public void onError(com.lzy.okgo.model.Response<LzyResponse<Topics>> response) {
//                        // handleError(response);
//                        Log.d("TAG", "err: " + response.body());
//                        if (response.body() == null) {
//                            // okgo();
//                        }
//                    }
//                });
//
//    }

}